home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_006 / microemacs / ansi.c next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  106 lines

  1. /*
  2.  * The routines in this file provide support for ANSI style terminals
  3.  * over a serial line. The serial I/O services are provided by routines in
  4.  * "termio.c". It compiles into nothing if not an ANSI device.
  5.  */
  6.  
  7. #include        <stdio.h>
  8. #include        "ed.h"
  9.  
  10. #if     ANSI
  11.  
  12. #define NROW    23                      /* Screen size.                 */
  13. #define NCOL    77                      /* Edit if you want to.         */
  14. #define BEL     0x07                    /* BEL character.               */
  15. #define ESC     0x1B                    /* ESC character.               */
  16.  
  17. extern  int     ttopen();               /* Forward references.          */
  18. extern  int     ttgetc();
  19. extern  int     ttputc();
  20. extern  int     ttflush();
  21. extern  int     ttclose();
  22. extern  int     ansimove();
  23. extern  int     ansieeol();
  24. extern  int     ansieeop();
  25. extern  int     ansibeep();
  26. extern  int     ansiopen();
  27.  
  28. /*
  29.  * Standard terminal interface dispatch table. Most of the fields point into
  30.  * "termio" code.
  31.  */
  32. TERM    term    = {
  33.         NROW-1,
  34.         NCOL,
  35.         &ansiopen,
  36.         &ttclose,
  37.         &ttgetc,
  38.         &ttputc,
  39.         &ttflush,
  40.         &ansimove,
  41.         &ansieeol,
  42.         &ansieeop,
  43.         &ansibeep
  44. };
  45.  
  46. ansimove(row, col)
  47. {
  48.         ttputc(ESC);
  49.         ttputc('[');
  50.         ansiparm(row+1);
  51.         ttputc(';');
  52.         ansiparm(col+1);
  53.         ttputc('H');
  54. }
  55.  
  56. ansieeol()
  57. {
  58.         ttputc(ESC);
  59.         ttputc('[');
  60.         ttputc('K');
  61. }
  62.  
  63. ansieeop()
  64. {
  65.         ttputc(ESC);
  66.         ttputc('[');
  67.         ttputc('J');
  68. }
  69.  
  70. ansibeep()
  71. {
  72.         ttputc(BEL);
  73.         ttflush();
  74. }
  75.  
  76. ansiparm(n)
  77. register int    n;
  78. {
  79.         register int    q;
  80.  
  81.         q = n/10;
  82.         if (q != 0)
  83.                 ansiparm(q);
  84.         ttputc((n%10) + '0');
  85. }
  86.  
  87. #endif
  88.  
  89. ansiopen()
  90. {
  91. #if     V7
  92.         register char *cp;
  93.         char *getenv();
  94.  
  95.         if ((cp = getenv("TERM")) == NULL) {
  96.                 puts("Shell variable TERM not defined!");
  97.                 exit(1);
  98.         }
  99.         if (strcmp(cp, "vt100") != 0) {
  100.                 puts("Terminal type not 'vt100'!");
  101.                 exit(1);
  102.         }
  103. #endif
  104.         ttopen();
  105. }
  106.